package com.itheima.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.itheima.constant.MessageConstant;
import com.itheima.constant.QuoteException;
import com.itheima.entity.PageResult;
import com.itheima.entity.QueryPageBean;

import com.itheima.entity.Result;
import com.itheima.pojo.CheckItem;
import com.itheima.service.CheckItemService;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/checkitem")
public class CheckItemController {
    @Reference
    private CheckItemService checkItemService;

    //分页查询
    @PostMapping("/findPage")
    public PageResult findPage(@RequestBody QueryPageBean queryPageBean) {
        return checkItemService.findPage(queryPageBean);
    }

    //根据id查询该检查项的具体数据
    @GetMapping("/findById")
    public Result findById(@RequestParam("id") Integer id) {

        return checkItemService.findById(id);

    }

    @GetMapping("/findAll")
    public Result findAll() {
        return checkItemService.findAll();
    }

    //编辑修改检查项数据
    @PostMapping("/edit")
    public Result edit(@RequestBody CheckItem checkItem) {

        return checkItemService.edit(checkItem);
    }

    //添加检查项
    @PostMapping("/add")
    public Result add(@RequestBody CheckItem checkItem) {
        return checkItemService.add(checkItem);
    }

    //删除检查项
    @GetMapping("/delete")
    public Result delete(@RequestParam("id") Integer id) {
        return checkItemService.delete(id);
    }
}